package br.com.news.business;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import br.com.news.business.utils.GenericBusiness;
import br.com.news.utils.business.exception.BusinessException;
import br.com.news.utils.business.interfaces.IAlternativaEnqueteBusiness;
import br.com.news.utils.database.beans.AlternativaEnqueteBean;
import br.com.news.utils.database.exception.DataBaseServiceException;
import br.com.news.utils.database.interfaces.IAlternativaEnqueteServiceDb;

@Named
public class AlternativaEnqueteBusiness extends GenericBusiness implements IAlternativaEnqueteBusiness{

	@Inject
	private IAlternativaEnqueteServiceDb alternativaEnqueteServiceDb;
	
	@Override
	public List<AlternativaEnqueteBean> findAll() throws BusinessException {
		try {
			return alternativaEnqueteServiceDb.findAll();
		} catch (DataBaseServiceException e) {
			throw new BusinessException(e);
		}
	}

	@Override
	public void save(AlternativaEnqueteBean alternativaEnquete)
			throws BusinessException {
		try {
			alternativaEnqueteServiceDb.save(alternativaEnquete);
		} catch (DataBaseServiceException e) {
			throw new BusinessException("Erro ao tentar salvar alternativa", e);
		}
	}

}
